#define _CRT_SECURE_NO_WARNINGS 1


#include <iostream>

using namespace std;

const int N = 2e5 + 10;

int n, m;
int a[N], b[N];
int ans;

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= m; i++) 
        cin >> a[i];
    for (int i = 1; i <= m; i++) 
        b[i] = i * i;

    if (a[m] != n) 
        a[++m] = n;

    for (int i = 0; i <= m; i++)
    {
        if (n < b[i]) 
            break;
        int sum = 1;
        for (int j = i + 1; j <= m; j++) 
            sum = max(sum, a[j] - a[j - i - 1]);
        ans = max(ans, sum - b[i]);
    }

    cout << ans;
    return 0;
}